//
//  ChatBar.h
//  JMXChatKit
//
//  Created by JMX on 2020/6/6.
//  Copyright © 2020 Uniauto. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "JMXChatDefines.h"

NS_ASSUME_NONNULL_BEGIN
/// 键盘弹出通知
UIKIT_EXTERN NSNotificationName const JMXKeyboardWillShowNotification;
/// 键盘收起通知
UIKIT_EXTERN NSNotificationName const JMXKeyboardWillHideNotification;
/// 键盘高度变化
UIKIT_EXTERN NSNotificationName const JMXKeyboardWillChangeFrameNotification;
/// 键盘高度key
UIKIT_EXTERN NSString *const JMXKeyboardHeightEndUserInfoKey;
/// 键盘弹出收起动画时长key
UIKIT_EXTERN NSString *const JMXKeyboardAnimationDurationUserInfoKey;

@class JMXChatBar;

@protocol JMXChatBarDataSource <NSObject>

@optional


/// 更多功能里功能集合，参考JMXChatActionType定义
- (NSArray *)actionsInChatBar:(JMXChatBar *)chatBar;

/// 子工具栏里的功能图片集合，image/imageName
- (NSArray *)subBarImagesInChatBar:(JMXChatBar *)chatBar;

@end

@protocol JMXChatBarDelegate <NSObject>

@optional

/// 输入文本内容高度发生变化时触发该事件
/// @param height 当前文本高度
- (void)chatBar:(JMXChatBar *)chatBar textHeightDidChange:(CGFloat)height;

/// 输入@字符@成员时出发该事件
- (void)chatBarDidAt:(JMXChatBar *)chatBar;

/// 点击键盘（或自定义表情键盘）中的发送按钮触发该事件
/// @param text 发送的文本内容
- (void)chatBar:(JMXChatBar *)chatBar textDidSend:(NSString *)text;


/// 点击更多功能里的功能时触发该事件
/// @param type 点击的功能类型
- (void)chatBar:(JMXChatBar *)chatBar didSelectActionOfType:(JMXChatActionType)type;


/// 是否显示子工具栏
- (BOOL)chatBarShouldShowSubBar:(JMXChatBar *)chatBar;

/// 点击子功能栏里的功能时触发该事件
/// @param index 功能索引
- (void)chatBar:(JMXChatBar *)chatBar didSelectSubBarAtIndex:(NSInteger)index;

/// 是否可以录音，建议在此处判断录音权限
- (BOOL)chatBarShouldRecord:(JMXChatBar *)chatBar;
/// 点击，开始录音触发该事件
- (void)chatBarRecordWillBegin:(JMXChatBar *)chatBar;
/// 抬起，录音结束触发该事件
- (void)chatBarRecordWillEnd:(JMXChatBar *)chatBar;
/// 手指离开录音按钮区域触发该事件
- (void)chatBarRecordWillCancel:(JMXChatBar *)chatBar;
/// 取消录音触发该事件
- (void)chatBarRecordDidCancel:(JMXChatBar *)chatBar;
/// 手指离开录音按钮后再次进入按钮区域触发该事件
- (void)chatBarRecordWillContinue:(JMXChatBar *)chatBar;

@end

@interface JMXChatBar : UIView

/// 文本消息输入框
@property (nonatomic, strong, readonly) UITextView *textView;

@property (nonatomic, weak) id<JMXChatBarDelegate> delegate;
@property (nonatomic, weak) id<JMXChatBarDataSource> dataSource;

/// 最大输入长度
@property (nonatomic, assign) NSInteger maxLength;


/// 当前聊天工具栏所处状态，参考JMXChatBarState定义
@property (nonatomic, assign, readonly) JMXChatBarState state;

- (void)chatBarWillAppear:(BOOL)animated;
- (void)chatBarWillDisappear:(BOOL)animated;

@end

NS_ASSUME_NONNULL_END
